<div class="vj_banner_cus_left widget-up-product" id="vj_banner_cus_left_id">
    <h3>ĐĂNG TIN MIỄN PHÍ</h3>

    <div>

        <input type="text" id="txtName" value="<?php echo $name ?>"
               placeholder="Tên sản phẩm">
        <select id="ddlProductCategory">
            <option value="0">Danh mục</option>
            <?php foreach ($categories as $item) { ?>
                <option
                    <?php echo $cat_id == $item->cat_id ? 'selected="selected"' : '' ?>
                    value="<?php echo $item->cat_id ?>"><?php echo $item->cat_name ?></option>
            <?php } ?>
        </select>
        <input type="button" id="btnUp" value="Đăng sản phẩm">
    </div>
</div>
<script type="text/javascript">
    $base = '<?php echo TreTodayUrl::home()?>'
    $(document).ready(function () {
        $("#btnUp").click(function () {
            var $cat_id = $("#ddlProductCategory").val();
            if ($cat_id == 0) {
                alert("Vui long chọn danh mục");
                return;
            }
            var $name = $("#txtName").val();

            var $data = {'name': $name, 'cat_id': $cat_id};
            $.ajax({
                'type': 'POST',
                'url': $base + '/ajax/checkLogin',
                'data': $data,
                success: function (data) {
                    window.location.href = data.url;
                }
            });

        });
    });
</script>